package com.springboot.demo.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.springboot.demo.common.customValidator.ListNotHasNull;
import com.springboot.demo.entity.*;
import com.springboot.demo.service.JobService;
import com.springboot.demo.utils.ResponseUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.ibatis.annotations.Update;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.Size;
import java.util.Date;
import java.util.List;

/**
 * @author wubc683
 * @desc
 * @date 2021-11-18 14:14
 */
//@RestController
//@Api(tags = "工单接口")
//@Validated
//public class JobController {
//    @Autowired
//    ResponseUtils responseUtils;
//    @Autowired
//    JobService jobService;
//
//    @GetMapping("/job/demand/all")
//    @ApiOperation(value = "获取所有维修需求")
//    @ApiOperationSupport(order = 10)
//    public ResponseUtils<List<maintainDemand>> getAllJobDemands(
//            @RequestParam(value = "search", required = false) String search,
//            @RequestParam(value = "state", required = false) Integer state,
//            @RequestParam(value = "startDate", required = false) Date startDate,
//            @RequestParam(value = "endDate", required = false) Date endDate,
//            @RequestParam(value = "contactName", required = false) String contactName,
//            @RequestParam(value = "contactPhone", required = false) String contactPhone,
//            @ApiParam(value = "排序字段(最多1个）,字段名+空格+排序方向,示例：升序[id asc]，降序[id desc]")
//            @RequestParam(required = false) String sort,
//            @Valid PageRequest pageRequest) {
//        Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
//        UserDetailsImpl userDetailsImpl = (UserDetailsImpl) principal;
//        User implUser = userDetailsImpl.getUser();
//        return responseUtils.buildSuccessResponse();
//    }
//
//    @GetMapping("/job/demand/{did}")
//    @ApiOperation(value = "获取一条维修需求")
//    @ApiOperationSupport(order = 20)
//    public ResponseUtils<maintainDemand> getOneJobDemand(@PathVariable("did") Long did) {
//        Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
//        UserDetailsImpl userDetailsImpl = (UserDetailsImpl) principal;
//        User implUser = userDetailsImpl.getUser();
//        return responseUtils.buildSuccessResponse();
//    }
//
//    @PostMapping("/job/demand")
//    @ApiOperation(value = "创建维修需求")
//    @ApiOperationSupport(order = 30)
//    public ResponseUtils saveJobDemand(@Valid @RequestBody maintainDemand demand) {
//        Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
//        UserDetailsImpl userDetailsImpl = (UserDetailsImpl) principal;
//        User implUser = userDetailsImpl.getUser();
//        return responseUtils.buildSuccessResponse();
//    }
//
//    @PutMapping("/job/demand")
//    @ApiOperation(value = "修改维修需求")
//    @ApiOperationSupport(order = 40)
//    public ResponseUtils updateJobDemand(@Valid @RequestBody maintainDemand demand) {
//        Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
//        UserDetailsImpl userDetailsImpl = (UserDetailsImpl) principal;
//        User implUser = userDetailsImpl.getUser();
//        return responseUtils.buildSuccessResponse();
//    }
//
//    @PostMapping("/job/demand/del")
//    @ApiOperation(value = "删除维修需求")
//    @ApiOperationSupport(order = 50)
//    public ResponseUtils deleteJobDemands(@Valid @RequestBody @ListNotHasNull @Size(min = 1) List<Long> demandLists) {
//        Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
//        UserDetailsImpl userDetailsImpl = (UserDetailsImpl) principal;
//        User implUser = userDetailsImpl.getUser();
//        return responseUtils.buildSuccessResponse();
//    }
//
//    @GetMapping("/job/plan/all")
//    @ApiOperation(value = "获取所有维保计划")
//    @ApiOperationSupport(order = 60)
//    public ResponseUtils<List<JobPlan>> getAllJobPlans(
//            @RequestParam(value = "search", required = false) String search,
//            @RequestParam(value = "state", required = false) Integer state,
//            @RequestParam(value = "type", required = false) String type,
//            @RequestParam(value = "sceneName", required = false) String sceneName,
//            @ApiParam(value = "排序字段(最多1个）,字段名+空格+排序方向,示例：升序[id asc]，降序[id desc]")
//            @RequestParam(required = false) String sort,
//            @Valid PageRequest pageRequest) {
//        Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
//        UserDetailsImpl userDetailsImpl = (UserDetailsImpl) principal;
//        User implUser = userDetailsImpl.getUser();
//        return responseUtils.buildSuccessResponse();
//    }
//
//    @GetMapping("/job/plan/{pid}")
//    @ApiOperation(value = "获取一条维保计划")
//    @ApiOperationSupport(order = 70)
//    public ResponseUtils<JobPlan> getOneJobPlan(@PathVariable("pid") Long pid) {
//        Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
//        UserDetailsImpl userDetailsImpl = (UserDetailsImpl) principal;
//        User implUser = userDetailsImpl.getUser();
//        return responseUtils.buildSuccessResponse();
//    }
//
//    @PostMapping("/job/plan")
//    @ApiOperation(value = "创建维保计划")
//    @ApiOperationSupport(order = 80)
//    public ResponseUtils saveJobPlan(@Valid @RequestBody JobPlan jobPlan) {
//        Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
//        UserDetailsImpl userDetailsImpl = (UserDetailsImpl) principal;
//        User implUser = userDetailsImpl.getUser();
//        return responseUtils.buildSuccessResponse();
//    }
//
//    @PutMapping("/job/plan")
//    @ApiOperation(value = "修改维保计划")
//    @ApiOperationSupport(order = 90)
//    public ResponseUtils updateJobPlan(@Valid @RequestBody JobPlan jobPlan) {
//        Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
//        UserDetailsImpl userDetailsImpl = (UserDetailsImpl) principal;
//        User implUser = userDetailsImpl.getUser();
//        return responseUtils.buildSuccessResponse();
//    }
//
//    @PostMapping("/job/plan/del")
//    @ApiOperation(value = "删除维修需求")
//    @ApiOperationSupport(order = 100)
//    public ResponseUtils deleteJobPlans(@Valid @RequestBody @ListNotHasNull @Size(min = 1) List<Long> jobPlanLists) {
//        Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
//        UserDetailsImpl userDetailsImpl = (UserDetailsImpl) principal;
//        User implUser = userDetailsImpl.getUser();
//        return responseUtils.buildSuccessResponse();
//    }
//
//    @GetMapping("/job/all")
//    @ApiOperation(value = "获取所有订单")
//    @ApiOperationSupport(order = 110)
//    public ResponseUtils<List<Job>> getAllJobs(
//            @RequestParam(value = "search", required = false) String search,
//            @RequestParam(value = "state", required = false) Integer state,
//            @RequestParam(value = "startDate", required = false) Date startDate,
//            @RequestParam(value = "endDate", required = false) Date endDate,
//            @RequestParam(value = "contactName", required = false) String contactName,
//            @RequestParam(value = "contactPhone", required = false) String contactPhone,
//            @ApiParam(value = "排序字段(最多1个）,字段名+空格+排序方向,示例：升序[id asc]，降序[id desc]")
//            @RequestParam(required = false) String sort,
//            @Valid PageRequest pageRequest) {
//        Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
//        UserDetailsImpl userDetailsImpl = (UserDetailsImpl) principal;
//        User implUser = userDetailsImpl.getUser();
//        return responseUtils.buildSuccessResponse();
//    }
//
//    @GetMapping("/job/{jid}")
//    @ApiOperation(value = "获取一条订单")
//    @ApiOperationSupport(order = 120)
//    public ResponseUtils<Job> getOneJob(@PathVariable("jid") Long jid) {
//        Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
//        UserDetailsImpl userDetailsImpl = (UserDetailsImpl) principal;
//        User implUser = userDetailsImpl.getUser();
//        return responseUtils.buildSuccessResponse();
//    }
//
//    @PostMapping("/job")
//    @ApiOperation(value = "创建订单")
//    @ApiOperationSupport(order = 130)
//    public ResponseUtils saveJob(@Valid @RequestBody Job job) {
//        Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
//        UserDetailsImpl userDetailsImpl = (UserDetailsImpl) principal;
//        User implUser = userDetailsImpl.getUser();
//        return responseUtils.buildSuccessResponse();
//    }
//
//    @PutMapping("/job")
//    @ApiOperation(value = "修改订单")
//    @ApiOperationSupport(order = 140)
//    public ResponseUtils updateJob(@Valid @RequestBody Job job) {
//        Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
//        UserDetailsImpl userDetailsImpl = (UserDetailsImpl) principal;
//        User implUser = userDetailsImpl.getUser();
//        return responseUtils.buildSuccessResponse();
//    }
//
//    @PostMapping("/job/del")
//    @ApiOperation(value = "删除订单")
//    @ApiOperationSupport(order = 150)
//    public ResponseUtils deleteJobs(@Valid @RequestBody @ListNotHasNull @Size(min = 1) List<Long> jobLists) {
//        Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
//        UserDetailsImpl userDetailsImpl = (UserDetailsImpl) principal;
//        User implUser = userDetailsImpl.getUser();
//        return responseUtils.buildSuccessResponse();
//    }
//}
